//
//  YNSMineMesNoticeCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/6/23.
//

#import "YNSMineMesNoticeCell.h"

@implementation YNSMineMesNoticeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.selectionStyle = 0;
    self.backgroundColor = [UIColor whiteColor];
    
    self.nameLab = [[UILabel alloc] init];
    self.nameLab.text = @"消息提醒";
    [self.contentView addSubview:self.nameLab];
    self.nameLab.textColor = [UIColor colorWithHexString:@"#11182F"];
    self.nameLab.font = PFRFont(16);
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    self.switchBtn = [[UISwitch alloc] init];
    [self.switchBtn setOnTintColor:[UIColor colorWithHexString:@"#1678FF"]];
    [self.contentView addSubview:self.switchBtn];
    //添加事件监听
    [self.switchBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
    [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(56);
        make.height.mas_equalTo(30);
        make.centerY.mas_equalTo(self.contentView);
        make.right.offset(-16);
    }];
}

- (void)switchAction:(UISwitch *)sender {
    if (self.valueBlock) {
        self.valueBlock(sender.on);
    }
}

@end
